package com.example.demo.controller;


import com.example.demo.entity.Doctor;
import com.example.demo.service.IDoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 咨询师信息表 前端控制器
 * </p>
 *
 * @author hyb
 * @since 2024-12-24
 */
@RestController
@RequestMapping("/doctor")
public class DoctorController {
    @Autowired
    private IDoctorService iDoctorService; // 假设您有一个名为IDoctorService的服务接口

    // 处理GET请求，获取咨询师列表
    @GetMapping("/list")
    public List<Doctor> list() {
        return iDoctorService.list();
    }

    // 处理POST请求，创建新的咨询师信息
    @PostMapping("/create")
    public Doctor create(@RequestBody Doctor doctor) {
        iDoctorService.save(doctor);
        return doctor;
    }

    // 根据ID查询咨询师信息
    @GetMapping("/{id}")
    public Doctor getDoctorById(@PathVariable Integer id) {
        return iDoctorService.getById(id);
    }

}
